package com.shopping_back.controller;

import com.shopping_back.common.Result;
import com.shopping_back.pojo.vo.PlaceOrderVO;
import com.shopping_back.service.IFullReductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

import static com.fasterxml.jackson.databind.type.LogicalType.Map;

@RestController
@RequestMapping("/api/fullReduction")
public class FullReductionController {

    @Autowired
    private IFullReductionService fullReductionService;

    @GetMapping("/activity")
    public Result getFullReductionActivity(@RequestParam Long activityId) {
        return fullReductionService.getFullReductionActivity(activityId);
    }

    @GetMapping("/items")
    public Result getFullReductionItems(@RequestParam Long activityId, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
        return fullReductionService.getFullReductionItems(activityId, page, size);
    }

    @PostMapping("/placeOrder")
    public Result placeFullReductionOrder(
            @RequestBody PlaceOrderVO request) {
        return fullReductionService.placeFullReductionOrder(
                request.getUserId(),
                request.getActivityId(),
                request.getSkuQuantities());
    }
}
